Variadic C functions now count arguments with ptrdiff_t.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 14 Jun 2011 18:57:19 +0000 (11:57 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 14 Jun 2011 18:57:19 +0000 (11:57 -0700)
commitb14ca77cac3bcfb8eccc60657d99f30b43bca795
tree1a532e58f11f03cc078976a14540c25de5f464f5
parent8ec8bf93a24f4ec3f29cf89da9542f141b537fe9
Variadic C functions now count arguments with ptrdiff_t.

This partly undoes my 2011-03-30 change, which replaced int with size_t.
Back then I didn't know that the Emacs coding style prefers signed int.
Also, in the meantime I found a few more instances where arguments
were being counted with int, which may truncate counts on 64-bit
machines, or EMACS_INT, which may be unnecessarily wide.
* lisp.h (struct Lisp_Subr.function.aMANY)
(DEFUN_ARGS_MANY, internal_condition_case_n, safe_call):
Arg counts are now ptrdiff_t, not size_t.
All variadic functions and their callers changed accordingly.
(struct gcpro.nvars): Now size_t, not size_t.  All uses changed.
* bytecode.c (exec_byte_code): Check maxdepth for overflow,
to avoid potential buffer overrun.  Don't assume arg counts fit in 'int'.
* callint.c (Fcall_interactively): Check arg count for overflow,
to avoid potential buffer overrun.  Use signed char, not 'int',
for 'varies' array, so that we needn't bother to check its size
calculation for overflow.
* editfns.c (Fformat): Use ptrdiff_t, not EMACS_INT, to count args.
* eval.c (apply_lambda):
* fns.c (Fmapconcat): Use XFASTINT, not XINT, to get args length.
(struct textprop_rec.argnum): Now ptrdiff_t, not int.  All uses changed.
(mapconcat): Use ptrdiff_t, not int and EMACS_INT, to count args.
19 files changed:
src/ChangeLog
src/alloc.c
src/bytecode.c
src/callint.c
src/callproc.c
src/character.c
src/charset.c
src/coding.c
src/data.c
src/dbusbind.c
src/editfns.c
src/eval.c
src/fns.c
src/font.c
src/frame.c
src/keyboard.c
src/lisp.h
src/process.c
src/xdisp.c